package com.bestcem.xm.common.core.config.mq.impl;

import com.alibaba.fastjson.JSON;
import com.bestcem.xm.common.core.config.mq.XmMessageProducer;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

/**
 * @ClassName: KafkaProducerImpl
 * @Description:
 * @Author: chenglong.yue
 * @Date: 2022/5/3 18:05
 */
@Slf4j
@Component
@ConditionalOnProperty(prefix = "application", name = "mqType", havingValue = "kafka")
public class KafkaProducerImpl extends XmMessageProducer {

    @Override
    public boolean send(String bindingName, Object msg) throws JsonProcessingException {
        if (log.isInfoEnabled()) {
            log.info("[kafka producer] send message. bindingName:{}, msg:{}", bindingName, JSON.toJSONString(msg));
        }
        return super.send(bindingName, msg);
    }
}
